package cn.sumpu.app.coolsk.dao.impl;

import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;

import cn.sumpu.app.coolsk.dao.CardNumDao;
import cn.sumpu.app.coolsk.domain.CardNum;
import cn.sumpu.app.coolsk.domain.Member;
import cn.sumpu.app.coolsk.exception.AppBusinessException;

public class CardNumDaoImpl extends SqlSessionDaoSupport implements CardNumDao{
	 /**
	  * 
	  */
	@Override
	public void insert(CardNum cardNum)throws AppBusinessException {
		
		try { 
			getSqlSession().insert("cn.sumpu.app.coolsk.persistence.CardNumMapper.insert",
					cardNum);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("insert database failure.", e);
			}
			throw new AppBusinessException("insert database failure.", e);
		}
	}
	@Override
	public CardNum getCardNumByMap(Map<String, Object> map) throws AppBusinessException{
		
		try {
			return (CardNum) getSqlSession()
					.selectOne(
							"cn.sumpu.app.coolsk.persistence.CardNumMapper.getCardNumByMap",map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getCardNumByMap failure.", e);
			}
			throw new AppBusinessException("getCardNumByMap failure.", e);
		}
	}
	//
	@Override
	public void updateCardNum(CardNum cardNum)throws AppBusinessException {
		
		try { 
			getSqlSession().update("cn.sumpu.app.coolsk.persistence.CardNumMapper.updateCardNum",
					cardNum);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("updateCardNum database failure.", e);
			}
			throw new AppBusinessException("updateCardNum database failure.", e);
		}
	}
	
}
